<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>父子组件使用</title>
</head>
<body>
<div id="app">
    <parent></parent>
</div>
<!-- 父组件模板 -->
<template id="parenttem">
    <div>
        <child src="../img/1.jpg" txt="首页"></child>
    </div>
</template>
<!-- 子组件模板 -->
<template id="sontem">
    <div>
        <img :src="src"/>
        <br />
        <span>{{txt}}</span>
    </div>
</template>
</body>
</html>
<script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
<script>
    new Vue({
        el: "#app",
        components: {
            "parent": {
                template: "#parenttem",
                components: {
                    "child": {
                        template: "#sontem",
                        props: ["txt","src"]
                    }
                }
            }
        }
    })
</script>